package easy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution_1403 {

    public List<Integer> minSubsequence(int[] nums) {
        int sum = 0;
        for (int num : nums) {
            sum += num;
        }
        Arrays.sort(nums);
        List<Integer> list = new ArrayList<>();
        int val = 0;
        for (int i = nums.length - 1; i >= 0; i--) {
            val += nums[i];
            list.add(nums[i]);
            if (val > (sum - val)) {
                break;
            }
        }
        return list;
    }

    public static void main(String[] args) {
        Solution_1403 model = new Solution_1403();
        System.out.println(model.minSubsequence(new int[]{4, 3, 10, 9, 8}));
        System.out.println(model.minSubsequence(new int[]{4, 4, 7, 6, 7}));
        System.out.println(model.minSubsequence(new int[]{6}));
    }
}
